﻿using UnityEngine;
using System.Collections;


namespace edu.wpi.cs.Project1
{
    /// <summary>
    /// A simple pupup text which is desplayed for a short time
    /// </summary>
    public class PopupText : MonoBehaviour
    {

        /// <summary>
        /// The speed to fly upward.
        /// </summary>
        public const float FLY_UP_SPEED = 75.0f;

        /// <summary>
        /// The popups text life timer.
        /// </summary>
        private float timeToLive = 1.0f;

        /// <summary>
        /// Use this for initialization
        /// </summary>
        void Start()
        {

        }

        /// <summary>
        /// Updates the popup text position.
        /// </summary>
        void Update()
        {
            this.transform.localPosition += Vector3.up * Time.deltaTime * FLY_UP_SPEED;

            timeToLive -= Time.deltaTime;

            if (timeToLive < 0)
            {
                this.GetComponent<TextMesh>().text = "";
                Destroy(this);
            }
        }
    }
}
